package org.jsbd.boss.dao.impl;

import java.util.List;
import org.jsbd.boss.dao.IBookDao;
import org.jsbd.boss.domian.Book;

public class BookDaoImpl extends CrackBaseDao implements IBookDao {

	@Override
	public void save(Book book) {
		super.insert("qy_book.insert_book", book);
	}

	@Override
	public void save(List<Book> list) {
		super.batchInsert("qy_book.insert_book", list);
	}

	@Override
	public void saveToTemp(List<Book> list) {
		super.batchInsert("qy_book.insert_book_temp", list);
	}

	@Override
	public void update(Book book) {
		super.update("qy_book.update_book", book);
	}

	@Override
	public void updateTotalMoney(Book book) {
		super.update("qy_book.update_book_total_money", book);
	}

	@Override
	public void updateFailCount(Integer id) {
		super.update("qy_book.update_book_fail_count", id);
	}

	// @Override
	// public int updateAvailableNum(Book book) {
	// // 乐观锁 减一
	// return super.update("qy_book.update_book_dec_available_num", book);
	// }

	@Override
	public Book get(Book book) {
		return (Book) super.queryForObject("qy_book.select_book_one", book);
	}

	@Override
	public Book getById(Integer id) {
		return (Book) super.queryForObject("qy_book.select_by_id", id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Book> getList(Book book) {
		return super.queryForList("qy_book.select_book_list", book);
	}

	@Override
	public Integer getListPageCount(Book book) {
		return super.queryForCount("qy_book.select_book_page_count", book);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Book> getGroupList(Integer bookGroupId) {
		return super.queryForList("qy_book.select_book_group_list", bookGroupId);
	}

	@Override
	public void delete(List<Integer> ids) {
		super.batchUpdate("qy_book.delete_book", ids);
	}

	/** 以下临时表 操作 **/
	@Override
	public Integer getTempListPageCount(Book book) {
		return super.queryForCount("qy_book.select_book_temp_page_count", book);
	}

	@Override
	@SuppressWarnings("unchecked")
	public List<Book> getTempListByPage(Book book) {
		return (List<Book>) super.queryForList("qy_book.select_book_temp_list", book);
	}

	@Override
	public Integer getTempCountByMarkAndName(Book book) {
		return super.queryForCount("qy_book.select_book_by_mark_and_name", book);
	}

	@Override
	public void clearTemp() {
		super.update("qy_book.clear_book_temp", 1);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Book> getTempList() {
		return super.queryForList("qy_book.select_all_book_temp_list");
	}

	@Override
	public Integer getTempCount() {
		return super.queryForCount("qy_book.select_book_temp_count");
	}

	@Override
	public Book getByMarkAndName(Book book) {
		return (Book) super.queryForObject("qy_book.select_book_by_mark_and_name", book);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Book getByMark(String mark) {
		return (Book) super.queryForObject("qy_book.select_book_by_mark", mark);
	}

	@Override
	public void updatePayMoneyById(Book book) {
		super.update("qy_book.update_book_pay_money_by_id", book);
	}

	@Override
	public void deleteByBookGroupId(Integer bookGroupId) {
		super.update("qy_book.delete_book_by_book_group_id", bookGroupId);
	}

	@Override
	public void saveBookRevertLog(Book book) {
		super.insert("qy_book.insert_book_revert_log", book);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Book> getRevertBookList() {
		return super.queryForList("qy_book.select_all_book_for_revert", 1);
	}

	@Override
	public Integer revertBookPayMoney(Integer bookId) {
		return super.update("qy_book.revert_book_pay_money_by_id", bookId);
	}

}
